<%@include file="head.jsp" %>	
<%@include file="nav.jsp" %>

	
<div id="content_test_url">

	<h1>Testeando la URL de Google con java</h1>
	<%@ page import="java.net.*" %>
	<%@ page import="java.io.*" %>
	<%	
   		URL myURL = new URL("https://www.google.com/");	
	%>
	
	<ol>
		<li>
			<span>url:</span>
			<span class="valor"><%=myURL %></span>
		</li>
		<li>
			<span>host:</span>
			<span class="valor"><%=myURL.getHost()%></span>
		</li>
		<li>
			<span>port:</span>
			<span class="valor"><%=myURL.getPort()%></span>
		</li>
		<li></li>
		<li></li>
	</ol>
	
	<div class="content_html">
		<%		
			try 
		    {	        			
		    	DataInputStream dis = new DataInputStream(myURL.openStream());
		        String inputLine;
		        while ((inputLine = dis.readLine()) != null) {
			        inputLine = inputLine.replace("/images/srpr/logo1w.png", "https://www.google.es/images/srpr/logo1w.png");
       
		            out.print(inputLine);
		        }
		        dis.close();
		    } catch (MalformedURLException me) {
		        out.print("MalformedURLException: " + me);
		    } catch (IOException ioe) {
		        out.print("IOException: " + ioe);
		    }
		 %>	    
	</div>

</div>

<%@include file="footer.jsp" %>		